﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Snai.CMS.Manage.DataAccess.Base;

namespace Snai.CMS.Manage {
    public class Program {
        public static void Main (string[] args) {
            var host = CreateWebHostBuilder (args).Build ();
            using (var serviceScope = host.Services.CreateScope ()) {
                var services = serviceScope.ServiceProvider;
                try {
                    var servicesContext = services.GetRequiredService<CMSContext> ();
                    SeedData.InitializeData (servicesContext);
                   

                } catch (System.Exception e) {
                    throw e;
                }
            }
            host.Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder (string[] args) =>
            WebHost.CreateDefaultBuilder (args)
            .UseStartup<Startup> ();
    }
}